package com.itheima.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.itheima.service.FilenameService;

@Controller
public class DownLoadController {

	
	@Autowired
	private FilenameService filenameService;
	
	
	@GetMapping("/download")
	public ResponseEntity<byte[]> fileDownload(HttpServletRequest request,
			@RequestParam("filename") String filename) throws Exception{
	   
		return filenameService.fileDownload(request, filename);
	}
	
}
